//
//  Dog.m
//  2、Person
//
//  Created by student on 16/3/11.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "Dog.h"

@implementation Dog

-(instancetype)init{

    if (self=[super init]) {
        [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(hungryDown:) userInfo:nil repeats:YES];
        self.hungry=100;
        self.die=NO;
    }
    return self;
}

-(void)setFirstName:(NSString *)firstName{
    _firstName=firstName;
    NSLog(@"主人你好!我叫%@,请多关照!",firstName);
}

-(NSString *)fullName{
    return [NSString stringWithFormat:@"%@.%@",self.firstName,self.lastName];
}


-(NSString *)lastName{
    if (_lastName==nil) {
        return @"华盛顿";
    }else{
        return _lastName;
    }
}

-(void)hungryDown:(NSTimer *)t{

    if (self.hungry>0) {
        self.hungry-=10;


        NSLog(@"%@的饥饿值为%i",self.fullName,self.hungry);
    }else{
        self.die=YES;
        NSLog(@"%@饿死了",self.fullName);
        [t invalidate];
    }
//    [self.degelate feed:self];
}

@end


